﻿using System;

namespace Panda.UI.Runtime
{
    public interface IRouter
    {
        public void Register(string pageId, IPage page, string layerId = null);
        public void Register(string layerId, ILayer layer);
        public IPage GetCurrentPage(string layerId = null);

        /// <summary>
        /// 关闭所有页面，打开到应用内的某个页面
        /// </summary>
        /// <param name="pageId"></param>
        /// <param name="data"></param>
        /// <param name="success"></param>
        /// <param name="fail"></param>
        /// <param name="complete"></param>
        /// <param name="layerId"></param>
        public abstract void ReLaunch(string pageId, object data, Action success, Action fail, Action complete, string layerId = null);

        /// <summary>
        /// 关闭当前页面，跳转到应用内的某个页面
        /// </summary>
        /// <param name="pageId"></param>
        /// <param name="data"></param>
        /// <param name="success"></param>
        /// <param name="fail"></param>
        /// <param name="complete"></param>
        /// <param name="layerId"></param>
        public abstract void RedirectTo(string pageId, object data, Action success, Action fail, Action complete, string layerId = null);

        /// <summary>
        /// 保留当前页面，跳转到应用内的某个页面
        /// </summary>
        /// <param name="pageId"></param>
        /// <param name="data"></param>
        /// <param name="isPopUp"></param>
        /// <param name="success"></param>
        /// <param name="fail"></param>
        /// <param name="complete"></param>
        /// <param name="createNewIfInHistory"></param>
        /// <param name="layerId"></param>
        public abstract void NavigateTo(string pageId, object data, Action success, Action fail, Action complete, bool createNewIfInHistory, string layerId = null);

        /// <summary>
        /// 关闭当前页面，返回上一页面或多级页面
        /// </summary>
        /// <param name="success"></param>
        /// <param name="fail"></param>
        /// <param name="complete"></param>
        /// <param name="layerId"></param>
        public abstract void NavigateBack(Action success, Action fail, Action complete, string layerId = null);
    }
}